﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using kim.Common;

namespace kim
{
    partial class List : kim.UI.ManagePage
    {
        protected string StrPage;
        protected int pageSize, pageIndex, typeid, fid, en, isT;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                typeid = kim.Common.KIMRequest.GetInt("typeid", 1);
                fid = KIMRequest.GetInt("fid", 1);
                GetStrPage();
                Label1.Text = "新闻中心";
              
            }
        }
     

        private void GetStrPage()
        {
            pageIndex = KIMRequest.GetInt("p", 1);
            string strWhere = string.Empty;
            string strUrl = string.Empty;
            strWhere = "ClassID=" + typeid + "and ChannelID=" + fid;
            strUrl = "List.aspx?p=__id__&typeid=" + typeid + "&fid=" + fid;
            pageSize = 10;
            pageIndex = KIMRequest.GetInt("p", 1);
            kim.BLL.eg_news bll = new kim.BLL.eg_news();
            int count = SqlDbHelper.GetPageCurrent("eg_news", strWhere);
            using (DataSet dt = bll.GetNewsPager(pageIndex, pageSize, "", "InTime Desc", strWhere))
            {
                rptlist.DataSource = dt;
                rptlist.DataBind();
            }
            StrPage = kim.Common.Utils.OutPageList(pageSize, pageIndex, count, strUrl, 8);
        }
        protected void lbtnqx_Click(object sender, CommandEventArgs e)
        {
            LinkButton l = (LinkButton)sender;
            Model.eg_news moNews = new BLL.eg_news().GetModel(int.Parse(l.CommandName));
            BLL.eg_news bllNews = new BLL.eg_news();
            if (moNews.DesignerID == 1)
            {
                moNews.DesignerID = 0;
                bllNews.Update(moNews);
                typeid = kim.Common.KIMRequest.GetInt("typeid", 1);
                fid = KIMRequest.GetInt("fid", 1);
                GetStrPage();
            }
            else {
                moNews.DesignerID = 1;
                bllNews.Update(moNews);
                typeid = kim.Common.KIMRequest.GetInt("typeid", 1);
                fid = KIMRequest.GetInt("fid", 1);
                GetStrPage();
            }
             
        }
    }
}

